package com.ruoyi.web.controller.mxerp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.mapper.MxWareMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MxWare;
import com.ruoyi.system.service.IMxWareService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 仓库查询Controller
 *
 * @author yushuaixm
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/mxerp/ware")
public class MxWareController extends BaseController {
    @Autowired
    private IMxWareService mxWareService;

    @Autowired
    private MxWareMapper mxWareMapper;


    @PostMapping("/getAllWare")
    public AjaxResult getAllWare(){
        return success(mxWareMapper.getAllWare());
    }

    /**
     * 查询仓库查询列表
     */
    @PreAuthorize("@ss.hasPermi('mxerp:ware:list')")
    @GetMapping("/list")
    public TableDataInfo list(MxWare mxWare) {
        startPage();
        List<MxWare> list = mxWareService.selectMxWareList(mxWare);
        return getDataTable(list);
    }

    /**
     * 导出仓库查询列表
     */
    @PreAuthorize("@ss.hasPermi('mxerp:ware:export')")
    @Log(title = "仓库查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MxWare mxWare) {
        List<MxWare> list = mxWareService.selectMxWareList(mxWare);
        ExcelUtil<MxWare> util = new ExcelUtil<MxWare>(MxWare.class);
        util.exportExcel(response, list, "仓库查询数据");
    }

    /**
     * 获取仓库查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('mxerp:ware:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mxWareService.selectMxWareById(id));
    }

    /**
     * 新增仓库查询
     */
    @PreAuthorize("@ss.hasPermi('mxerp:ware:add')")
    @Log(title = "仓库查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MxWare mxWare)
    {
        return toAjax(mxWareService.insertMxWare(mxWare));
    }

    /**
     * 修改仓库查询
     */
    @PreAuthorize("@ss.hasPermi('mxerp:ware:edit')")
    @Log(title = "仓库查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MxWare mxWare)
    {
        return toAjax(mxWareService.updateMxWare(mxWare));
    }

    /**
     * 删除仓库查询
     */
    @PreAuthorize("@ss.hasPermi('mxerp:ware:remove')")
    @Log(title = "仓库查询", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mxWareService.deleteMxWareByIds(ids));
    }
}
